import {request} from "@/utils";

// 1. 封装文章频道请求API
function ChannelAPI() {
    return request({
        url: "/channels",
        method: "GET"
    })
}

// 2. 封装文章发布请求API
function PublishAPI(PublishData) {
    return request({
        url: "/mp/articles?draft=false",
        method: "POST",
        data: PublishData
    })
}

// 3. 文章列表请求API
function getArticleListAPI(params) {
    return request({
        url: "/mp/articles",
        method: "GET",
        params
    })
}

// 4. 删除文章请求API
function deleteArticleAPI(id) {
    return request({
        url: `/mp/articles/${id}`,
        method: "DELETE"
    })
}

// 5. 获取文章详情请求API
function getArticleDetailAPI(id) {
    return request({
        url: `/mp/articles/${id}`,
        method: "GET"
    })
}

// 6. 更新文章请求API
function updateArticleAPI(data) {
    return request({
        url: `/mp/articles/${data.id}`,
        method: "PUT",
        data
    })
}

export {
    ChannelAPI,
    PublishAPI,
    getArticleListAPI,
    deleteArticleAPI,
    getArticleDetailAPI,
    updateArticleAPI
}
